﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net; //For webClient
using Graph;

namespace Crawler
{
    //Implementation of IHTTP
    public class HTTP : IHTTP
    {        
        //Method that opens a connection to a webpage with a given url, 
        //and returns the source code as a string
        public string GetSourceCode(string url)
        {
            string source = null;
            using (WebClient webClient = new WebClient())
            {
                try
                {
                    source = webClient.DownloadString(url);
                }
                catch (Exception ex)
                {
                    return source;
                }
            }
            
            return source;
        }
    }
}
